//
//  BusinessManageTableViewCell.m
//  AnXin100
//
//  Created by Sakura on 2018/11/8.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "BusinessManageTableViewCell.h"

@interface BusinessManageTableViewCell ()

@property (nonatomic, strong) UIImageView *productImage;

@property (nonatomic, strong) UILabel *titleLabel;

@property (nonatomic, strong) UILabel *priceLabel;

@property (nonatomic, strong) UILabel *salesLabel;

@property (nonatomic, strong) UILabel *turnoverLabel;

@property (nonatomic, strong) UILabel *inventoryLabel;

@property (nonatomic, strong) UILabel *timeLabel;

@property (nonatomic, strong) UIButton *shareBtn;

@property (nonatomic, strong) UIButton *operationBtn;

@property (nonatomic, strong) UIView *firstLineView;

@property (nonatomic, strong) UIView *twoLineView;

@end

@implementation BusinessManageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}

- (void)createCell {
    _productImage = [UIImageView new];
    _productImage.image = [UIImage imageNamed:@"grape"];
    [self.contentView addSubview:_productImage];
    
    _titleLabel = [UILabel new];
    _titleLabel.textColor = [UIColor colorWithHex:0x333333];
    _titleLabel.font = [UIFont systemFontOfSize:14];
    _titleLabel.text = @"无籽西瓜";
    [self.contentView addSubview:_titleLabel];
    
    _priceLabel = [UILabel new];
    _priceLabel.font = [UIFont systemFontOfSize:12];
    _priceLabel.textColor = COLOR_ORG;
    _priceLabel.text = @"￥6.00";
    [self.contentView addSubview:_priceLabel];
    
    _salesLabel = [UILabel new];
    _salesLabel.font = [UIFont systemFontOfSize:12];
    _salesLabel.textColor = [UIColor colorWithHex:0x999999];
    _salesLabel.text = @"总销量 20";
    [self.contentView addSubview:_salesLabel];
    
    _inventoryLabel = [UILabel new];
    _inventoryLabel.font = [UIFont systemFontOfSize:12];
    _inventoryLabel.textColor = [UIColor colorWithHex:0x999999];
    _inventoryLabel.text = @"库存 600";
    [self.contentView addSubview:_inventoryLabel];
    
    _timeLabel = [UILabel new];
    _timeLabel.font = [UIFont systemFontOfSize:12];
    _timeLabel.textColor = [UIColor colorWithHex:0x999999];
    _timeLabel.text = @"添加2018/10/29";
    [self.contentView addSubview:_timeLabel];
    
    _turnoverLabel = [UILabel new];
    _turnoverLabel.font = [UIFont systemFontOfSize:12];
    _turnoverLabel.textColor = [UIColor colorWithHex:0x999999];
    _turnoverLabel.text = @"成交额 20.00";
    [self.contentView addSubview:_turnoverLabel];
    
    _shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _shareBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [_shareBtn setTitleColor:[UIColor colorWithHex:0x333333] forState:UIControlStateNormal];
    [_shareBtn setTitle:@"分享" forState:UIControlStateNormal];
    _shareBtn.backgroundColor = COLOR_LINE;
    _shareBtn.layer.cornerRadius = 4;
    [self.contentView addSubview:_shareBtn];
    
    _operationBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _operationBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    _operationBtn.backgroundColor = COLOR_ORG;
    [_operationBtn setTitle:@"上架" forState:UIControlStateNormal];
    _operationBtn.layer.cornerRadius = 4;
    [self.contentView addSubview:_operationBtn];
    
    _firstLineView = [[UIView alloc] init];
    _firstLineView.backgroundColor = [UIColor colorWithHex:0xf5f5f5];
    [self.contentView addSubview:_firstLineView];
    
    _twoLineView = [UIView new];
    _twoLineView.backgroundColor = [UIColor colorWithHex:0xf5f5f5];
    [self.contentView addSubview:_twoLineView];

}

- (void)layoutSubviews {
    
    _productImage.frame = CGRectMake(10, 10, 90, 90);
    _titleLabel.frame = CGRectMake(110, 10, SCREEN_WIDTH - 120, 22.5);
    _priceLabel.frame = CGRectMake(110, 32.5, SCREEN_WIDTH - 120, 22.5);
    _salesLabel.frame = CGRectMake(110, 55, (SCREEN_WIDTH - 120) / 2, 22.5);
    _turnoverLabel.frame = CGRectMake(CGRectGetMaxX(_salesLabel.frame), 55, (SCREEN_WIDTH - 120) / 2, 22.5);
    _inventoryLabel.frame = CGRectMake(110, 77.5, _salesLabel.mj_w, 22.5);
    _timeLabel.frame = CGRectMake(_turnoverLabel.mj_x, 77.5, _salesLabel.mj_w, 22.5);
    
    _firstLineView.frame = CGRectMake(0, 110, SCREEN_WIDTH, 1);
    _twoLineView.frame = CGRectMake(0, 149, SCREEN_WIDTH, 1);
    
    _operationBtn.frame = CGRectMake(SCREEN_WIDTH - 60, 117.5, 50, 25);
    _shareBtn.frame = CGRectMake(CGRectGetMinX(_operationBtn.frame) - 60, 117.5, 50, 25);
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

@end
